<template>
  <el-card shadow="never" class="border-0" v-loading="loading">
    <el-form :model="form" label-width="160px">
      <el-form-item label="物流查询key">
        <el-input v-model="form.ship" style="width: 50%;" placeholder="appkey"/>
        <small class="text-gray-500 flex mt-1">用于查询物流信息，<a target="_blank" href="https://www.jisuapi.com/api/express/">接口申请（仅供参考）</a></small>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submit">保存</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup>
  import { ref,reactive,onMounted } from 'vue'
  import { toast } from '@/utils'
  import { 
    getSysconfigApi,
    setSysconfigApi,
  } from '@/api/sysconfig'

  const form = reactive({
    ship:""
  })

  const loading = ref(false)

  function getData(){
    loading.value = true
    getSysconfigApi().then(d=>{
      for (const k in form) {
        form[k] = d[k]
      }
    }).finally(()=>{
      loading.value = false
    })
  }

  onMounted(()=>getData())
  const submit = ()=>{
    loading.value = true
    setSysconfigApi(form).then(res=>{
      toast("修改成功")
      getData()
    }).finally(()=>{
      loading.value = false
    })
  }
</script>

<style scoped></style>
